Week 8 Embedded Programming

This week we will learn coding with electronics, it will take long time to practice but I think it will be fun to learn.

Weekly Assignment

  • Group assignment: compare the performance and development workflows for other architectures
  • Individual assignment: read a microcontroller data sheet; program your board to do something, with as many different programming languages and programming environments as possible

Individual assignment

Datasheet is a document that summarizes the performance and other technical characteristics of a product in details that allows engineers to understand the role of the component in the overall system. Typically, datasheet is created by the manufacturer.

Read ATtiny44Datasheet

AT tiny 44 Pin Descriptions

  • VCC: Supply voltage.
  • GND: Ground.
  • Port B (PB3:PB0): The Port B output buffers have symmetrical drive characteristics with both high sink and source capability except PB3 which has the RESET capability.
  • RESET: Reset input. Tells AVR to enter programming mode. The reset pin can also be used as a (weak) I/O pin.
  • Port A (PA7:PA0): Port A is a 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). Port A has alternate functions as analog inputs for the ADC, analog comparator, timer/counter, SPI and pin change interrupt as described in “Alternate Port Functions”
  • SCK - Serial Clock
  • MISO - Master-in, Slave-output
  • MOSI - Master-out, Slave-in
  • Main features of AVR 8bits (ATtiny24/44/84) microcontroller:

  • High performance, low power
  • AVR enhanced RISC (Reduced Instruction Set Computer) Architecture: better real time performance; generally have lower cycles per instruction (CPI) than a complex instruction set computer

  • Twelve Programmable I/O Lines
  • Memories: In-System, Self-programmable Flash Program Memory (2K/4K byte): downloading and uploading program code by the MCU itself EEPROM Data Memory (128/256 bytes): store data processed during the run time SRAM Data Memory (128/256 bytes): store non-volatile data (saved regardless if the power is on/off); changeable during run-time
  • Clock: clock sources: built-in clock or external resonators clock subsystem: ADC, I/O, CPU, Flash
  • Timer/Counter: allows accurate program execution timing (event management) and wave generation
  • Analog Comparator: compares the voltage on the positive pin and the negative pin.
  • Special Features: On-chip Debug System; Low Power Idle, ADC Noise Reduction, Standby and Power-down Modes; Enhanced Power-on Reset Circuit; Internal Calibrated Oscillator. On-chip Temperature Sensor
  • Play with arduino UNO board

    Aduino Fade Led

    Connect bread board, 1 × 330Ω resistor, led and arduino Uno like this:

    Connect the short leg of led to ground.

    Chose arduino UNO board and port.

    Fade led code:

    Video:

    Arduino Buton control Motor

  • If button is pressed, rotate servo motor to 90 degree
  • If button is pressed again, rotate servo motor back to 0 degree.
  • Connect button and servo motor to arduino.For digital module, there are two pins, one goes to numbers, the other one goes to ground; For analog modules, there are three pins, one goes to vcc(5V/3.3v), one goes to GND, one goes to analog pin (numbers with wave.)

    The code is below:

    Video:

    Arduino Nano Radar project:

  • I alaso use Arduino Nano to make a radar that has ultrasonic wave sensor as input and buzzer as output.
  • Programming the Echohello Board

  • Connect the FabTinyISP programmer to the laptop and get it to be recognized as an Atmel USB Device/USBTinySPI.
  • Download Arduino IDE to Program.
  • Arduino IDE setting:
  • Installing ATtiny support in Arduino using the built-in boards manager.

    1. Open the preferences dialog in the Arduino software.
    2. Find the “Additional Boards Manager URLs” field near the bottom of the dialog.
    3. Paste the following URL into the field (use a comma to separate it from any URLs which has already been added):
    4. Select ATTiny22/44/84 from Tools/Boards menu.
    5. Select ATTiny44 from Tools/Processor menu
    6. Selct 20MHz clock (external) from Tools/Clock menu
    7. Select USBTinyISP from Tools/Programmer
    8. Then select Tool/Burn Bootloader
  • Write/Debug code: Use hello board button to control LED.My LED is on pin 3; my button is on pin 7.
  • Compile Code: This steps converts programming language code into hexidecimal machine language instructions that can be understood and executed by the microcontrollers.
  • Upload Code: With the ‘Hex File’ of the program instructions created, it can be uploaded into the target programmer.
  • After I test my Helloboard, I forgot to take video, and I also can't find my hello board later, so I will use my final project GINO board for this week's assignement.

    Programme in Gino board: connect Fab ISP with GINO board.

    FabISP layout, just to remember the pins, I also write it on my notebook.
    Gino board layout:
    Attiny 44 Pin out: I need to use Aduino IDE to compile the attiny, so I need to figure out attiny44 pinout in arduino.
    Attiny 44 pinout in arduino.
    Gino board Pinout in Arduino
    Check Gino board

    I haven't use GINO board for a while, when I connect it with a LED it doesn't work at first. I use multimeter to check the connect first, then I also try to connect it with different pins, then I realize pin 2 is stop working, so I use other pins.

    I use a touch sensor as input and led as output:

    It's working well.

    Download Link: